package com.springmvc.web.majiang.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.springmvc.web.majiang.entity.User;

/**
 * 
 * @ClassName: IndexController 
 * @author wangruchao
 * @date 2017年12月18日 上午11:47:35
 */
@Controller
@RequestMapping
public class IndexController {

	@RequestMapping
	public String index(Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("userInfo");
		if (user == null) {
			System.err.println("session is null");
			return "index";
		}
		model.addAttribute("userid", user.getId());
		return "redirect:/room";
	}

}
